package com.lz.fruitday.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.lz.fruitday.R;
import com.lz.fruitday.bean.Data;
import com.lz.fruitday.utils.ImageLoaderUtil;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 * Created by liuZhi
 * 2015/10/23
 */
public class FriendAdapter extends AppBaseAdapter<Data> {
    DisplayImageOptions options;
    public FriendAdapter(List<Data> list, Context context) {
        super(list, context);
        options= ImageLoaderUtil.getDefaultOptions();
    }

    @Override
    public ViewHolder getViewHolder(int position, View convertView, ViewGroup parent) {
        Data data=list.get(position);
        ViewHolder vh=ViewHolder.get(context,convertView,parent, R.layout.item_food_friend_layout);
        ImageView ivFace= (ImageView) vh.findViewById(R.id.iv_userface);
        TextView tvUserName= (TextView) vh.findViewById(R.id.tv_username);
        TextView tvTitle= (TextView) vh.findViewById(R.id.tv_friend_title);
        TextView tvDesc= (TextView) vh.findViewById(R.id.tv_description);
        TextView tvWorth= (TextView) vh.findViewById(R.id.tv_worth_num);
        TextView tvComment= (TextView) vh.findViewById(R.id.tv_comment_num);

        ImageLoader.getInstance().displayImage(data.getUserface(),ivFace,options);
        tvUserName.setText(data.getUsername());
        tvTitle.setText(data.getTitle());
        tvDesc.setText(data.getDescription());
        tvWorth.setText(String.valueOf(data.getWorth_num()));
        tvComment.setText(String.valueOf(data.getComment_num()));
        return vh;
    }
}
